<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="../static/vue.min.js"></script>
<script src="../elements/element.js"></script>
<link rel="stylesheet" href="../elements/element.css">
<script src="../static/jquery-1.8.0.js"></script>
<body>

<div id="App">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="活动ID" prop="promotion_id">
            <el-input v-model="ruleForm.promotion_id"></el-input>
        </el-form-item>
        <el-form-item label="活动场次ID" prop="promotion_session_relation_id">
            <el-input v-model="ruleForm.promotion_session_relation_id"></el-input>
        </el-form-item>
        <el-form-item label="SKU_ID" prop="sku_id">
            <el-input v-model="ruleForm.sku_id"></el-input>
        </el-form-item>
        <el-form-item label="秒杀价钱" prop="seckill_price">
            <el-input-number v-model="ruleForm.seckill_price" :min="0" :precision="2" :step="0.1"
                             :max="1000"></el-input-number>
        </el-form-item>
        <el-form-item label="秒杀总量" prop="seckill_count">
            <el-input-number v-model="ruleForm.seckill_count" :min="0" :step="1" step-strictly></el-input-number>
        </el-form-item>
        <el-form-item label="每人限购数量" prop="seckill_limit">
            <el-input-number v-model="ruleForm.seckill_limit" :min="0" :step="1" step-strictly></el-input-number>
        </el-form-item>
        <el-form-item label="排序" prop="seckill_sort">
            <el-slider
                    v-model="ruleForm.seckill_sort"
                    show-input>
            </el-slider>
        </el-form-item>

        <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
    </el-form>
</div>
<script>
    let vue = new Vue({
        el: "#App",
        data() {
            return {
                ruleForm: {
                    promotion_id: '',
                    promotion_session_relation_id: '',
                    sku_id: '',
                    seckill_price: '',
                    seckill_count: '',
                    seckill_limit: '',
                    seckill_sort: 0,
                },
                rules: {
                    promotion_id: [
                        {required: true, message: '请输入', trigger: 'blur'},
                    ],
                    promotion_session_relation_id: [
                        {required: true, message: '请输入', trigger: 'blur'}
                    ],
                    sku_id: [
                        {required: true, message: '请填写', trigger: 'blur'}
                    ],
                    seckill_sort: [
                        {required: true, message: '请填写', trigger: 'blur'}
                    ]
                }
            };
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => { //validate被校验的表单项 prop 值，校验是否通过，错误消息（如果存在）
                    console.log(valid)
                    if (valid) {
                        console.log(this.ruleForm);
                        alert('submit!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        }
    })
</script>


</body>
</html>